from __future__ import annotations

import os
from tkinter import Tk, filedialog
from typing import Optional


def pick_pdf_file() -> Optional[str]:
	"""Open a Windows file picker dialog to choose a PDF file.

	Returns the selected file path or None if cancelled.
	"""
	# Avoid showing full Tk window
	root = Tk()
	root.withdraw()
	root.attributes('-topmost', True)

	filetypes = [("PDF files", "*.pdf"), ("All files", "*.*")]
	filename = filedialog.askopenfilename(
		title="Select PDF",
		filetypes=filetypes,
	)

	root.destroy()

	if not filename:
		return None
	return filename
